#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created by master on 2017/3/11


import paramiko

# create SSH object
ssh = paramiko.SSHClient()

# allow to connection the host who was not in file know_hosts
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
# connect to server
ssh.connect(hostname="cl.salt.com", port=22, username="alex", password=123456)

# execute command
stdin, stdout, stderr = ssh.exec_command("df")

# get the result of execution

result = filter(lambda x: x is not None, [stdout.read(), stderr.read()])[0]

# close the connection
ssh.close()
